Vue Js Detect Browser Langauge: Vue.js provides a simple way to detect the browser language using the navigator object The language property returns the language of the browser that is used by the visitor. navigator.language is a JavaScript property that is used to indicate the language of the browser or system, such as Spanish or French . In this tutorial, we’ll show you how to use VueJs to determine the browser’s default language.
this.result = "Browser Language : " + navigator.language;
How to get the browser language using Vue Js?
Getting the browser language in Vue.js can be done with the navigator.language property. The navigator language property is a read-only property that can be used to get the preferred language of the browser.
Vue Js Get current browser language | Example
<div id="app">
<button @click="myFunction">click me</button>
<p>{{result}}</p>
</div>
<script type="module">
import { createApp } from "vue";
createApp({
data() {
return {
result: "",
};
},
methods: {
myFunction() {
this.result = "Browser Language : " + navigator.language;
},
},
}).mount("#app");
</script>